// ** React Imports
import { useEffect, useRef } from 'react'
import * as echarts from 'echarts'

export default () => {
  const charRef = useRef(null)

  useEffect(() => {
    initChart()
  }, [])

  const initChart = () => {
    const chart = echarts.init(charRef.current)
    chart.setOption({
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'shadow',
        },
      },
      grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true,
      },
      xAxis: {
        type: 'value',
        boundaryGap: [0, 0.01],
        axisLine: { lineStyle: { color: '#95f3f5' } },
        splitLine: {
          show: false,
        },
      },
      yAxis: {
        type: 'category',
        data: ['钙粉', '辅料1', '辅料2', '辅料3', '辅料4', '辅料5'],
        axisLine: { lineStyle: { color: '#95f3f5' } },
        splitLine: {
          show: false,
        },
      },
      series: [
        {
          type: 'bar',
          data: ['0.55', '0.65', '0.73', '0.87', '0.92', '0.99'],
          itemStyle: {
            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
              { offset: 0, color: '#83bff6' },
              { offset: 0.5, color: '#61dafb' },
              { offset: 1, color: '#61dafb' },
            ]),
          },
          textStyle: {
            color: '#67E0E3',
            fontSize: 14,
            fontWeight: 'bold',
          },
        },
      ],
    })
  }
  return (
    <div className="left-two">
      <div className="box-title">易缺物料存库</div>
      <div className="box-content" style={{ height: '395px' }}>
        <div
          className="char"
          ref={charRef}
          style={{ height: '100%', width: '100%' }}
        ></div>
      </div>
    </div>
  )
}
